import React, { Component } from "react";
import { Text, View } from "react-native";
import CustomHeader from "../../components/CustomHeader";
import QRCode from "react-native-qrcode";

export class PersonQrCode extends Component {
  constructor(props) {
    super(props);
    this.state = {
      pId: props.navigation.getParam("pId", 0),
      pName: props.navigation.getParam("pName")
    };
  }
  render() {
    const { pName, pId } = this.state;
    return (
      <View>
        <CustomHeader title={pName + "-二维码"} />
        <View
          style={{
            marginTop: 100,
            display: "flex",
            justifyContent: "center",
            alignItems: "center"
          }}
        >
          <QRCode
            value={JSON.stringify({
              qType: "person",
              pId,
              pName
            })}
            size={200}
            bgColor="black"
            fgColor="white"
          />
          <Text
            style={{
              marginTop: 20
            }}
          >
            扫描二维码,成为 {pName} 的监护人
          </Text>
        </View>
      </View>
    );
  }
}

export default PersonQrCode;
